package cn.melonlib.aap.user.model.entity;

import cn.melonlib.aap.user.model.enums.AuthMethod;
import cn.melonlib.aap.user.model.enums.LoginClient;
import cn.melonlib.cores.commons.model.anno.MelonEntityId;
import cn.melonlib.cores.commons.model.enums.IdType;
import cn.melonlib.cores.commons.model.enums.IdValueType;
import cn.melonlib.cores.commons.model.support.number_id.MelonLibLongIdEntity;
import cn.melonlib.cores.model.anno.ModelComment;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Type;

import javax.persistence.*;

@Data
@EqualsAndHashCode(callSuper = true)
@ModelComment("用户登陆记录")
@Entity(name = "AccountLoginRecord")
@Table(name = "user_account_login_record")
@MelonEntityId(type = IdType.SNOW_FLAKE,IdValueType = IdValueType.LONG)
public class AccountLoginRecord extends MelonLibLongIdEntity {

    @ManyToOne(cascade = CascadeType.REFRESH,fetch = FetchType.LAZY)
    @JoinColumn(name = "account_id")
    @ModelComment("所属账户")
    private Account account;

    @Enumerated(EnumType.STRING)
    @ModelComment("登陆客户端")
    private LoginClient loginClient=LoginClient.H5;

    @Enumerated(EnumType.STRING)
    @ModelComment("验证类型")
    private AuthMethod authMethod=AuthMethod.PASSWORD;

    @Column@Lob@Basic(fetch = FetchType.LAZY)
    @Type(type = "org.hibernate.type.TextType")
    @ModelComment("客户端信息，agent信息")
    private String clientInfo;

    @ModelComment("客户端请求IP")
    private String clientIp;

    @ModelComment("登陆时间")
    private Long loginDateTime=System.currentTimeMillis();


}
